/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.uta.tsrh.model;
 

/**
 *
 * @author Ethan
 */
public class User {
    //private int id = 0;

    private String userId = "";

    private String userName = "";
    
    private String password = "";
    
    private String emailId = "";
    
    private String permissionKey = "" ;
    
    
    public User()
    {
        super();
    }

    public User(/*int id,*/ String userid, String username, String emailid, String passwordhash)
    {
	//this.id = id;
	this.userId = userid;
	this.userName = username;
	this.password = passwordhash;
	this.emailId = emailid;
    }

    public String getUserId()
    {
        return this.userId;
    }
    
    public void setUserId(String userid)
    {
	if(this.userId.equals(""))
	    this.userId = userid;
    }
    
    public void setPermissionValue(String v)
    {
        this.permissionKey = v;
    }
    
    public String getPermissionValue()
    {
        return this.permissionKey;
    }

    public String getUserName()
    {
        return this.userName;
    }
    
    public void setUserName(String username)
    {
	if(this.userName.equals(""))
	    this.userName = username;
    }
    
    /*public String getPassword()
    {
        return this.password;
    }*/
    
    public void setPassword(String passwordhash)
    {
	if(this.password.equals(""))
	    this.password = passwordhash;
    }

    public String getEmail()
    {
        return this.emailId;
    }
    
    public void setEmail(String email)
    {
	if(this.emailId.equals(""))
	    this.emailId = email;
    }
    
    public String getHashedPW()            
    {        
        return HashMD5.hashpw(this.password);
        
    }
    
        
    public boolean checkLogin(String passwordCandidate)
    {
	if(this.password.equals(""))
	    return false;
	       
	return HashMD5.checkpw(HashMD5.hashpw(passwordCandidate), this.password);
    }

    @Override
    public String toString()
    {
        return "User [userId=" + userId + ", userName=" + userName + ", emailId="
            + emailId + "]";
    }
}
